
<%@page contentType="text/html" import="java.util.*" %>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<%-- 
    Document   : topkphrases
    Created on : Mar 9, 2012, 11:25:28 AM
    Author     : lsf
--%>

<jsp:useBean id="now" class="java.util.Date" /> 

<SCRIPT language="javascript">

 
    function addRowToTopK(tableID,phraseTableId) {

        
        try {
            var phraseTable = document.getElementById(phraseTableId);
            var phrrowCount = phraseTable.rows.length;

 
            for(var ii=0; ii<phrrowCount; ii++) {
                var comrow = phraseTable.rows[ii];
                var comchkbox = comrow.cells[0].childNodes[0];
                var comval= comrow.cells[1].childNodes[0].value;
                       
                if(null != comchkbox && true == comchkbox.checked) {

                    if(comrowCount <= 1) {
                        alert("Cannot delete all the rows.");
                        break;
                    }
 
                    var table = document.getElementById(tableID);
 
                    var rowCount = table.rows.length;
                    var row = table.insertRow(rowCount);
 
                    var colCount = table.rows[0].cells.length;
                    
                    for(var i=0; i<colCount; i++) {
 
                        var newcell = row.insertCell(i);
 
                        newcell.innerHTML = table.rows[0].cells[i].innerHTML;
                        //alert(newcell.childNodes);
                        switch(newcell.childNodes[0].type) {
                            case "text":
                                newcell.childNodes[0].value = comval;
                                break;
                            case "checkbox":
                                newcell.childNodes[0].checked = false;
                                break;
                            case "select-one":
                                newcell.childNodes[0].selectedIndex = 0;
                                break;
                         
                        }
                    }
                    
                    

                }
 
            }
        }catch(e) {
            alert(e);
        }
 
 
 
 
    }
 
    function deleteRowFromTopK(tableID) {
        try {
            var comtable = document.getElementById(tableID);
            var comrowCount = comtable.rows.length;

 
            for(var ii=0; ii<comrowCount; ii++) {
                var comrow = comtable.rows[ii];
                var comchkbox = comrow.cells[0].childNodes[0];
                var comval= comrow.cells[1].childNodes[0].value;
                       
                if(null != comchkbox && true == comchkbox.checked) {

                    if(comrowCount <= 1) {
                        alert("Cannot delete all the rows.");
                        break;
                    }
                    comtable.deleteRow(ii);
                    comrowCount--;
                    ii--;
                }
 
            }
        }catch(e) {
            alert(e);
        }
 
    }
 
</SCRIPT>




<div id="indexRightColumn">
    <h2>Step 2- Select top K Phrases</h2> 
    <div class="phraseBox3">
        <h3>Phrases from Document</h3> 
        <div class="table">
            
            <TABLE id="phraseTable" cellpadding="0" cellspacing="0" border="1" >

                <tbody>

                    
                    <%Iterator itr;%>
                            <% List data1 = (List) request.getAttribute("allphrases");%>
                            <%    for (itr = data1.iterator(); itr.hasNext();) {
                            %>
                         

                            <TR class="${(((j)%2)==0) ? 'white':'lightBlue'}">
                        <TD width="5%" ><INPUT type="checkbox" name="comchk"/></TD>
                       
                        <TD width="95%"><input type="text" name="txt" value="<%=itr.next()%>" size="200%" /></TD>
                    </TR>
                            <%}%>

                </tbody>
            </TABLE>

        </div>
       <br/> <div class="pushButton">
            <input type="submit" value=">>" name="push" onclick="addRowToTopK('dataTable','phraseTable')"/>

        </div>
        <div class="pullButton">
            <input type="submit" value="<<" name="pull" onclick="deleteRowFromTopK('dataTable')"/>
        </div>
    
                    <h3>Top K Phrases</h3> 
        <div class="table">
            

            <TABLE id="dataTable"  cellpadding="0" cellspacing="0" border="1">


                <tbody>
                    <TR class="${(((j)%2)==0) ? 'white':'lightBlue'}">
                        <TD width="5%"><INPUT type="checkbox" name="chk"/> </TD>
                        <TD width="75%"><input type="text" name="txt" value="" size="100%"/></TD>
                        <TD width="20%">
                            <SELECT name="score">

                                <OPTION value="vimp">V.Important</OPTION>
                                <OPTION value="imp">Important</OPTION>
                                <OPTION value="avr">Average</OPTION>

                            </SELECT>
                        </TD>
                    </TR>
                </tbody>
            </TABLE>


        </div>


        <div class="buttonPos">
           <br/> <a href="uploaddoc">
                <input type="submit" value="Back" name="back" />
            </a>
            Select Top k Phrases
            <a href="classify">
                <input type="submit" value="Next" name="next" />
            </a>


        </div>
    </div>


</div>
